import Axios from "@/config/axios";

const headers = {
  post_json: { "Content-Type": "application/json; charset=UTF-8" }
};

export default {
  /**
   * 账号密码登陆
   * @param {Api.Login} 入参数据
   * @return {Api.Response}
   */
  Login(params: Api.Login): Promise<Api.Response> {
    return Axios.post("/prod-api/login", params);
  },

  /**
   * 验证码登陆
   * @param {Api.PhonenumberLogin} 入参数据
   * @return {Api.Response}
   */
  PhonenumberLogin(params: Api.PhonenumberLogin): Promise<Api.Response> {
    return Axios.post("/prod-api/phonenumberLogin", params);
  },

  /**
   * 获取用户信息接口
   * @return {Api.Response}
   */
  GetInfo(): Promise<Api.Response> {
    return Axios.get("/prod-api/getInfo");
  },

  /**
   * 发送验证码
   * @return {Api.Response}
   * 说明：发送验证码接口服务端不能带token，所以加个token=false，axios的拦截器会对token=false的入参进行判断
   */
  CaptchaSMS(params: Api.CaptchaSMS): Promise<Api.Response> {
    return Axios.get("/prod-api/captchaSMS", { params: { ...params, token: false } });
  },

  /**
   * 登陆发送验证码
   * @return {Api.Response}
   * 说明：发送验证码接口服务端不能带token，所以加个token=false，axios的拦截器会对token=false的入参进行判断
   */
  LoginCaptchaSMS(phonenumber: string): Promise<Api.Response> {
    return Axios.get("/prod-api/loginCaptchaSMS", { params: { phonenumber, token: false } });
  },

  /**
   * 获取首页模块路由信息
   */
  GetRouters(): Promise<Api.Response> {
    return Axios.get("/prod-api/getRouters");
  },

  /**
   * 获取首页项目数量
   */
  MyProject(): Promise<Api.Response> {
    return Axios.get("/prod-api/project/info/myProject");
  },

  /**
   * 项目负责人下拉列表接口
   */
  GetLeaderList(): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/portal/leaderList");
  },

  /**
   * 获取我的消息
   */
  GetMyMessageList(params: Api.MyMessageList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/portal/myMessageList", { params });
  },

  /**
   * 获取人员清单
   */
  GetPersonnelList(params: Api.PersonnelList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/portal/personnelList", { params });
  },

  /**
   * 获取项目清单
   */
  GetProjectList(params: Api.ProjectList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/portal/projectList", { params });
  },

  /**
   * 我的便签
   */
  GetMyNoteList(params: Api.MyNoteList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/portal/myNoteList", { params });
  },

  /**
   * 项目工作台查询接口，即我的项目
   */
  GetMyProjectList(params: Api.ProjectWorkbenchList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/portal/projectWorkbenchList", { params });
  },

  /**
   * 专家清单
   */
  GetExpertList(params: Api.ExpertList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/portal/expertList", { params });
  },

  /**
   * 项目概况
   */
  GetProjectDetail(id: string): Promise<Api.Response> {
    return Axios.get(`/prod-api/mobile/project/${id}`);
  },

  /**
   * 项目成员
   */
  GetProjectMember(params: any): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/project/memberList", { params });
  },

  /**
   * 项目干系人
   */
  GetProjectStakeholderList(params: any): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/project/stakeholderList", { params });
  },

  /**
   * 业务管理
   */
  GetBusinessManagementList(params: Api.ProjectBusinessList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/project/businessManagementList", { params });
  },

  /**
   * 业务概况
   */
  GetBusinessDetail(id: string): Promise<Api.Response> {
    return Axios.get(`/prod-api/mobile/business/${id}`);
  },

  /**
   * 业务手册
   */
  GetBusinessManualList(params: Api.BusinessManualList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/portal/businessManualList", { params });
  },

  /**
   * 典型案例
   */
  GetBusinessTypicalCaseList(params: Api.BusinessTypicalCaseList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/portal/typicalCaseList", { params });
  },

  /**
   * 成果校审
   */
  GetBusinessResultsReviewList(params: Api.BusinessResultsReviewList): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/business/resultsReviewList", { params });
  },

  /**
   * 获取项目文档树
   */
  GetBusinessProjectDocTree(params: Api.BusinessProjectDocTree): Promise<Api.Response> {
    return Axios.get("/prod-api/mobile/business/projectDocTree", { params });
  },

  /**
   * 是否为项目负责人接口
   */
  IsProjectLeader(params: Api.IsProjectLeader): Promise<Api.Response> {
    return Axios.get("/prod-api/project/info/isProjectLeader", { params });
  },

  /**
   * 获取便签详情
   */
  GetNoteDetail(guid: string): Promise<Api.Response> {
    return Axios.get(`/prod-api/mobile/note/${guid}`);
  },

  /**
   * 保存便签
   */
  SaveNoteDetail(params: Api.SaveNote): Promise<Api.Response> {
    if (params.guid) {
      return Axios.put(`/prod-api/mobile/note`, params, {
        headers: { ...headers.post_json }
      });
    } else {
      return Axios.post(`/prod-api/mobile/note`, params, { headers: { ...headers.post_json } });
    }
  },

  /**
   * 便签维护-获取关联项目列表接口
   */
  GetNoteProjectList(): Promise<Api.Response> {
    return Axios.get(`/prod-api/mobile/note/getProjectList`);
  },

  /**
   * 便签维护-获取关联业务列表接口
   */
  GetNoteBusinessList(projectGuid: string): Promise<Api.Response> {
    return Axios.get(`/prod-api/mobile/note/getBusinessList`, { params: { projectGuid } });
  },

  /**
   * 便签维护-获取关联干系人列表接口
   */
  GetNoteStakeholderList(params: Api.NoteStakeholderList): Promise<Api.Response> {
    return Axios.get(`/prod-api/mobile/note/getStakeholderList`, { params });
  },

  /**
   * 项目主页-项目合同接口
   */
  GetProjectContractList(params: Api.ProjectContractList): Promise<Api.Response> {
    return Axios.get(`/prod-api/mobile/project/contractList`, { params });
  },

  /**
   * 便签维护-删除便签接口
   */
  DeleteNote(guids: string): Promise<Api.Response> {
    return Axios.delete(`/prod-api/mobile/note/${guids}`);
  },

  /**
   * 修改手机号接口
   */
  UpdatePersonMobile(params: Api.UpdatePersonMobile): Promise<Api.Response> {
    return Axios.put(`/prod-api/system/user/profile`, params, {
      headers: { ...headers.post_json }
    });
  },

  /**
   * 通过旧密码修改密码
   */
  UpdatePwdByOld(params: Api.UpdatePwdByOld): Promise<Api.Response> {
    return Axios.put(`/prod-api/system/user/profile/updatePwd`, params);
  },

  /**
   * 通过验证码修改密码
   */
  UpdatePwdByCode(params: Api.UpdatePwdByCode): Promise<Api.Response> {
    return Axios.post(`/prod-api/system/user/editPassword`, params);
  },

  /**
   * 项目主页-项目文档接口
   */
  FileQueryTree(params: Api.FileQueryTree): Promise<Api.Response> {
    return Axios.get(`/prod-api/mobile/project/fileQueryTree`, { params });
  },

  /**
   * 我的关注
   */
  GetFocusProject(): Promise<Api.Response> {
    return Axios.get(`/prod-api/mobile/portal/focusProject`);
  },

   /**
   * 我的展示项目
   */
    GetProjectShowLibrary(params: Api.ShowProjectList): Promise<Api.Response> {
      return Axios.get("/prod-api/projectShowLibrary/list", { params });
    },

    /**
   * 项目概况
   */
  GetShowProjectDetail(guid: string): Promise<Api.Response> {
    return Axios.get(`/prod-api/project/info/${guid}`);
  },

  /**
   * 项目概况
   */
   industryCategoryTreeTwo(): Promise<Api.Response> {
    return Axios.get(`/prod-api/system/industryCategory/treeTwo`);
  },
};
